package binarysearch.test392;

/**
 * 判断子序列
 * @author code_yc
 * @version 1.0
 * @date 2020/7/13 11:48
 */
public class Solution1 {

    public boolean isSubsequence(String s, String t) {
        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();
        int c1 = 0, c2 = 0;
        while (c2 < ct.length) {
            if (c1 == cs.length) {
                return true;
            }
            if (cs[c1] == ct[c2]) {
                c1++;
                c2++;
            } else {
                c2++;
            }
        }
        return c1 == cs.length;
    }
}
